package cz.cvut.fel.nur.rcp.classes;

import java.util.Date;

public class Ingredient {

	private String name;
	private String type;
	private QuantityType quantityType;
	private Date defaultExpiration = new Date();

	public QuantityType getQuantityType() {
		return quantityType;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public Date getDefaultExpiration() {
		return defaultExpiration;
	}

	public void setDefaultExpiration(Date defaultExpiration) {
		this.defaultExpiration = defaultExpiration;
	}

	public Ingredient(String name, QuantityType quantityType) {
		this.name = name;
		this.quantityType = quantityType;
	}

	@Override
	public boolean equals(Object o) {
		if (o != null)
			return o.toString().equals(this.toString());
		return false;
	}

	@Override
	public String toString() {
		return name;
	}

	@Override
	public int hashCode() {
		
		String text = name + quantityType.meaning;
		
		int code = text.hashCode();
				
		return code;
	}
	
	public enum QuantityType {
		
		GRAM("g"), MILILITER("ml"), ITEM("ks");
		
		public String meaning;
		
		private QuantityType(String m) {
			meaning = m;
		}
	}
}
